<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layuiAdmin 网站用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiAdmin/dist/layuiadmin/style/admin.css?v={$version}" media="all">
    <link rel="stylesheet" href="/Font-Awesome-master/css/font-awesome.min.css">
    <script src="/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
    <script src="/js/jquery-2.1.1.min.js"></script>
    <style>
        #mc {
            height: 100vh;
            width: 100vw;
            overflow: hidden;
            position: fixed;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999999;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .icon {
            width: 28px;
            height: 28px;
            line-height: 28px;
            border: 1px solid #e6e6e6;
            border-top-color: rgb(230, 230, 230);
            border-right-color: rgb(230, 230, 230);
            border-bottom-color: rgb(230, 230, 230);
            border-left-color: rgb(230, 230, 230);
            text-align: center;
            border-radius: 1px;
            -webkit-transition: all .4s ease;
            transition: all .4s ease;
            float: left;
            list-style: none;
        }

        .layui-table-body {
            z-index: 0;
        }

        .layui-input-block {
            margin-left: 0;
        }

        .layui-btn .layui-icon {
            position: unset;
            vertical-align: middle;
        }
    </style>
</head>

<body>
<div id="mc">
    <img style="max-height: 90%;max-width: 90%;" src="" alt="">
</div>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div style="margin-bottom: 30px;">
                <button type="button" class="layui-btn layui-btn-primary" lay-href="{:url('read')}?id={$id}">基本信息</button>
                <button type="button" class="layui-btn layui-btn-normal">剧本</button>
                <button type="button" class="layui-btn layui-btn-primary" lay-href="{:url('cwbb')}?id={$id}">财务报表</button>
            </div>
        </div>
        <div class="layui-card-body">
            <div class="layui-btn-group" style="padding-bottom: 10px;">

            </div>
            <table id="demo" lay-filter="test"></table>
        </div>
    </div>
</div>
<!--库存设置-->
<script type="text/html" id="list_number_stock">
    <input class="data_stock" data_id="{{d.id}}" type="number" value="{{d.stock}}"
           style="width:100px;border:1px solid #d7d7d7;border-radius:5px;line-height:30px;padding:0 5px;" max="999">
</script>
<!--佣金设置-->
<script type="text/html" id="list_number_yj_price">
    <input class="data_yj_price" data_id="{{d.id}}" type="number" value="{{d.yj_price}}"
           style="width:100px;border:1px solid #d7d7d7;border-radius:5px;line-height:30px;padding:0 5px;" max="999">
</script>
<!--成本价格设置-->
<script type="text/html" id="list_number_cb_price">
    <input class="data_cb_price" data_id="{{d.id}}" type="number" value="{{d.cb_price}}"
           style="width:100px;border:1px solid #d7d7d7;border-radius:5px;line-height:30px;padding:0 5px;" max="999">
</script>
<!--销售价格设置-->
<script type="text/html" id="list_number_price">
    <input class="data_price" data_id="{{d.id}}" type="number" value="{{d.price}}"
           style="width:100px;border:1px solid #d7d7d7;border-radius:5px;line-height:30px;padding:0 5px;" max="999">
</script>
<script type="text/html" id="list_setting">
    <div class="layui-btn-group">
        {block name="setting_botton"}
        <button type="button" onclick="data_delete({{d.id}})" class="layui-btn  layui-btn-sm layui-bg-red delete">删除
        </button>
        <button type="button" onclick="data_upload({{d.id}})" class="layui-btn  layui-btn-sm upload">详情
        </button>
        {/block}
    </div>
</script>
<!--开关-->
<script type="text/html" id="check">
    {{# if( d.is_show == 1) { }}
    <input type="checkbox" name="is_show" lay-skin="switch" checked value="1" data_id="{{d.id}}">
    {{# }else if( d.is_show == 2) { }}
    <input type="checkbox" name="is_show" lay-skin="switch" value="2" data_id="{{d.id}}">
    {{# } }}
</script>
<!--系统图标-->
<script type="text/html" id="list_icon">
    {{#if (d.icon){ }}
    <div class="icon"><i class="{{d.icon}}"></i></div>
    {{#} }}
</script>
<!--常规图片-->
<script type="text/html" id="list_image">
    <img src="{{d.image}}" onclick="fdtop('{{d.image}}')" alt="">
</script>
{block name="js"}
{/block}
<!-- 配置文件 -->
<script type="text/javascript" src="/plug/UEditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/plug/UEditor/ueditor.all.js"></script>
{block name="layui"}
<script>
    function data_delete(id) {
        //删除按钮操作
        layui.use('layer', function () {
            var $ = layui.$
                , table = layui.table
                , layer = layui.layer;
            layer.confirm('确定删除吗？', function (index) {

                //执行 Ajax 后重载
                $.ajax({
                    'url': "{:url('script/delete')}",
                    'method': 'POST',
                    'data': {id: id},
                    'success': function (res) {
                        if (res.code == 200) {
                            layer.msg('删除成功', {
                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                            }, function () {
                                table.reload('demo');
                            });
                        } else {
                            layer.msg(res.message);
                        }
                    }
                })
            });
        })
    }

    function data_upload(id) {
        //编辑按钮操作
        layui.use('layer', function () {
            var $ = layui.$
                , table = layui.table
                , layer = layui.layer;


            var index = layer.open({
                type: 2
                , title: '详情'
                , content: 'jb_read.html' + '?id=' + id
                , maxmin: true
                , area: ["{$popup_size.width}", "{$popup_size.height}"]
                , btn: ['关闭']
            });
            layer.full(index);

        });
    }

    layui.config({
        base: '/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'useradmin', 'table', 'layer', 'laydate'], function () {

        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , layer = layui.layer
            , laydate = layui.laydate
        laydate.render({
            elem: '#time_time'
            , type: 'datetime'
            , range: '到'
            , format: 'yyyy-M-d H:m:s'
        });
        //表格
        var web_table = "{$table}";
        web_table = JSON.parse(web_table.replace(/&quot;/g, '"'));
        "{if $cs_url}"
        var url = "{:url('jb_list')}" + "{$cs_url}";
        "{else}"
        var url = "{:url('jb_list')}";
        "{/if}"
        url = url.replace(/&amp;/g, '&');
        console.log(url, 111)
        table.render({
            elem: '#demo'
            , limit: 50
            , url: url//数据接口
            , page: true //开启分页
            , cols: [web_table]
        });
        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;

            //执行重载
            table.reload('demo', {
                where: field
            });
        });

        //事件
        var active = {
            batchdel: function () {
                //批量删除按钮操作
                var checkStatus = table.checkStatus('demo')
                    , checkData = checkStatus.data; //得到选中的数据

                if (checkData.length === 0) {
                    return layer.msg('请选择数据');
                }

                var prompt = layer.prompt({
                    formType: 1
                    , title: '敏感操作，请验证口令'
                }, function (value, index) {
                    if (value !== '123456') {
                        return layer.msg('口令错误');
                    }
                    layer.closeAll();
                    var id = '';
                    for (var i = 0; i < checkData.length; i++) {
                        id += checkData[i]['id'] + ','
                    }
                    layer.confirm('确定删除吗？', function (index) {

                        //执行 Ajax 后重载
                        $.ajax({
                            'url': "{:url('delete')}",
                            'method': 'POST',
                            'data': {id: id},
                            'success': function (res) {
                                if (res.code == 200) {
                                    layer.msg('删除成功', {
                                        time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                    }, function () {
                                        table.reload('demo');
                                    });
                                } else {
                                    layer.msg(res.message);
                                }
                            }
                        })
                    });
                });
            }
        };
        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    //关闭弹出层
    $("#mc").click(function () {
        $("#mc").hide();
    })
</script>
{/block}
</body>

</html>